package zheezes.protocol.impl.wt;

import zheezes.util.ByteUtil;

public class DataId {
	private short id;

	public DataId() {
	}

	public DataId(short val) {
		this.id = val;
	}

	public DataId(String s) {
		setValue(s);
	}
	
	public void setValue(short val) {
		id = val;
	}
	
	public void setValue(String s) {
		try {
			id = ByteUtil.ctos(ByteUtil.stoa(s.toCharArray()));
		} catch (NumberFormatException e) {
		}
	}

	public int setBytes(byte[] buf, int offset, int max) {
		id = ByteUtil.bctos(buf, offset);
		return size();
	}

	public int getBytes(byte[] buf, int offset) {
		ByteUtil.bstoc(buf, offset, id);
		return size();
	}

	public int size() {
		return 2;
	}
}
